package shopping;

import java.sql.Connection;
import java.sql.PreparedStatement;

import com.bean.ywj.DBcon;

public class OrderOperation {
	private Connection conn;
	private PreparedStatement pstmt;
	public void saveOrder(userinfo bookorder) {
		try {
			conn=DBcon.getConnection();
			String sql="insert into bookorder (username,zipcode,phone,creditcard,total) values(?,?,?,?,?)";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, bookorder.getUsername());
			pstmt.setString(2, bookorder.getZipcode());
			pstmt.setString(3, bookorder.getPhone());
			pstmt.setString(4, bookorder.getCreditcard());
			pstmt.setDouble(5, bookorder.getTotal());
			pstmt.executeUpdate();
		
	}catch(Exception e) {
		e.printStackTrace();
	}
	finally {
		DBcon.closeConnection(conn);
		DBcon.closeStatement(pstmt);
	}

}
}